Conversation
rename: middleware file
bbc74f9 to
e335493
Compare
s3rius
approved these changes
Apr 19, 2025
s3rius
previously approved these changes
Apr 19, 2025
s3rius
previously approved these changes
Apr 19, 2025
fix: condition
02f642b to
e6fe9e0
Compare
s3rius
approved these changes
Apr 19, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem It Solves
In many real-world scenarios, tasks may fail due to transient issues like network instability or temporary unavailability of external services. Without a retry mechanism, such failures require manual intervention. This middleware provides automatic retry logic, reducing the need for manual restarts and increasing overall system resilience.
Key Features
• ✅ Retry support with configurable maximum number of attempts (max_retries)
• ⏱️ Customizable delay between retries (delay)
• 📈 Support for exponential backoff (use_delay_exponent)
• 🎲 Optional jitter to randomize delay and reduce retry bursts (use_jitter)
• 🏷️ Label-based control at the task level:
• retry_on_error
• max_retries
• delay
• ⏳ Ability to use a custom ScheduleSource for flexible rescheduling
• ❌ Optionally replaces the task result with NoResultError until retries are exhausted (no_result_on_retry)
How It Works
When a task raises an exception:
1. The middleware checks if retries are enabled via the retry_on_error label.
2. If the retry count hasn’t reached the maximum, the task is rescheduled with a computed delay.
3. If no_result_on_retry is enabled, the task result is temporarily replaced with NoResultError, allowing for deferred handling.